package com.example.service.impl;

import com.example.mapper.SupplierMapper;
import com.example.pojo.PageBean;
import com.example.pojo.Supplier;
import com.example.service.SupplierService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class SupplierServiceImpl implements SupplierService {

    @Autowired
    SupplierMapper supplierMapper;


    @Override
    public PageBean getSupplier(Supplier supplier,Integer page, Integer pageSize) {

        //设置分页参数
        PageHelper.startPage(page,pageSize);
        List<Supplier> list = supplierMapper.getSupplier(supplier);
        Page<Supplier> p= (Page<Supplier>) list;
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }

    @Override
    public Integer changeSupplier(Supplier supplier) {

        return supplierMapper.changeSupplier( supplier);
    }

    @Override
    public Integer deleteSupplier(String id) {
        return supplierMapper.deleteSupplier(id);
    }

    @Override
    public Integer addSupplier(Supplier supplier) {
        return supplierMapper.addSupplier(supplier);
    }

    @Override
    public List<Supplier> getSupplierList() {
        return supplierMapper.getSupplierList();
    }
}
